﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CabDemo.Models;

namespace CabDemo.Controllers
{
    public class ProductController : Controller
    {
        private UserModelDataContext _db;
        public UserModelDataContext db
        {
            get
            {
                if (_db == null) _db = new UserModelDataContext();
                return _db;
            }
        }

        //
        // GET: /Product/

        public ActionResult Index()
        {
            var categs = db.sp_cab_get_product_categs();
            return View(categs);
        }

        //
        // GET: /Product/Products/id

        public ActionResult Products(int id)
        {
            var products = db.sp_cab_get_products_by_categ(id);
            return View(products);
        }

        //
        // GET /Product/Pay/id

        public ActionResult Pay(int id)
        {
            if (Request.IsAuthenticated)
            {
                DbHelper.SendPinCode();
                return View();
            }
            else
                return RedirectToAction("LogOn", "User");

        }

        //
        // GET /Product/CheckPin/
        [HttpPost]
        public ActionResult CheckPin(UserModelDataContext model)
        {
            return View();
        }
    }
}
